package apitalkroom1;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    private ServerSocket serverSocket;

    public Server() {
        try {
            System.out.println("服务器启动...");
            serverSocket = new ServerSocket(8089);
            System.out.println("服务器启动成功...");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void start() {


        try {
            System.out.println("等待客户端连接...");
            Socket socket = serverSocket.accept();
            System.out.println("一个客户端连接成功" + socket.getRemoteSocketAddress());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Server server = new Server();
        server.start();;
    }
}
